package com.xdjd.mobile.business.dao.daoservice.member;

import com.xdjd.mobile.business.dao.mapper.member.MemberUserWalletPoDao;
import com.xdjd.mobile.business.entity.model.member.MemberUserWalletPo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * Created by Administrator on 2019/1/9 0009.
 */
@Service
public class MemberUserWalletPoService {

    @Autowired
    private MemberUserWalletPoDao memberUserWalletPoDao;

    public void saveWallet(MemberUserWalletPo po) {
        po.setCreateTime(new Date());
        po.setModifyTime(new Date());
        memberUserWalletPoDao.save(po);
    }

    public MemberUserWalletPo findWalletByMemberId(Long memberId) {
        return memberUserWalletPoDao.getByProperty("member_id", memberId);
    }

    public int reduceBalance(Long memberId, Long money) {
        return memberUserWalletPoDao.reduceBalance(memberId, money);
    }
}
